package di.module;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

import com.f2prateek.rx.preferences2.RxSharedPreferences;

import javax.inject.Singleton;
import app.OkApplication;
import dagger.Module;
import dagger.Provides;

@Module
public abstract class AppModule {

    @Singleton
    @Provides
    static SharedPreferences providePreferences(OkApplication application) {
        SharedPreferences preferences =
                PreferenceManager.getDefaultSharedPreferences(application);
        return preferences;
    }
    @Singleton
    @Provides
    static RxSharedPreferences provideRxSharedPreferences(SharedPreferences sharedPreferences) {
        return RxSharedPreferences.create(sharedPreferences);
    }


    @Singleton
    @Provides
    static Context provideApplicationContext(Application application) {
        return application;
    }
}